package com.bj.zspace.cat.controller;

import com.dianping.cat.Cat;
import com.dianping.cat.message.Event;
import com.dianping.cat.message.Message;
import com.dianping.cat.message.Transaction;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @Author:liuwenqing
 * @Date:2024/12/25 15:38
 * @Description:
 **/
@RestController
public class LimitTest {
    @GetMapping(value = "/limit/transaction")
    public String limitTransaction() throws InterruptedException {
        for (int i = 1; i < 210; i++) {
            for (int j = 1; j < 210; j++) {
                Transaction child = Cat.newTransaction("T1:" + i, "name:" + j);
                TimeUnit.MILLISECONDS.sleep(2);
                child.setStatus(Message.SUCCESS);
                child.complete();
            }
        }
        return "ok";
    }
    @GetMapping(value = "/limit/event")
    public String limitEvent() throws InterruptedException {
        // event
        for (int i = 1; i < 210; i++) {
            for (int j = 1; j < 210; j++) {
                TimeUnit.MILLISECONDS.sleep(2);
                Cat.logEvent("E1:" + i, "name:" + j);
            }
        }
        return "ok";
    }


}
